#!/bin/bash

to=$1
subject=$2
message=$3
data='{"to":"'$to'","subject":"'$subject'","message":'$message'}'
log_file=/tmp/zbx_alert.log
now=`date +"%F %T"`

function local_log(){
    echo "======New Alert====== $now ======" >> $log_file
    echo "Subject:" >> $log_file
    echo $subject >> $log_file
    echo "To:" >> $log_file
    echo $to >> $log_file
    echo "Message:" >> $log_file
    echo $message >> $log_file
}


function alert(){
    curl -H "Content-Type: application/json" -X PUT -d "$data" http://{JUMPSERVER_URL}/api/v1/alert/alert/update/
}

alert
local_log